

def clear_cache():
	from django.core.cache import cache
	from shutil import rmtree
	import os.path
	#delete all files in cache dir
	if os.path.exists(cache._dir):
		rmtree(cache._dir)
	

def expire_page(path):
	from django.core.cache import cache
	from django.http import HttpRequest
	from django.utils.cache import get_cache_key
	from urlparse import urlparse

	#normalize path (skip params and # pointers)
	urlparts = urlparse(path)

	request = HttpRequest()
	request.path = urlparts.path
	key = get_cache_key(request)
	if key:
		if cache.has_key(key):   
			cache.delete(key)
